package com.wf.ew.system.controller;

import com.wf.ew.common.BaseController;
import com.wf.ew.common.JsonResult;
import com.wf.ew.common.PageResult;
import com.wf.ew.system.model.Dictionary;
import com.wf.ew.system.service.DictionaryService;
import org.apache.poi.ss.formula.functions.T;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 *
 * controller
 * @author : Doman
 * @date : 2019-08-06 16:04:44
 * @version ：1.0
 */

@Controller
@RequestMapping("/system/dictionary")
public class DictionaryController extends BaseController {

	@Autowired
	private DictionaryService dictionaryService;
	
	/**
	 * 页面
	 **/
	@RequiresPermissions("dictionary:view")
	@RequestMapping()
	public String dictionary() {
		return "system/dictionary.html";
	}

	/**
	 * 查询列表
	 */
	@RequiresPermissions("dictionary:view")
	@RequestMapping(value = "/list", produces = {"text/html;charset=UTF-8;"})
	@ResponseBody
	public String list(PageResult<T> page, Dictionary dictionary){
		return dictionaryService.list(page, dictionary);
	}

	/**
	 * 新增
	 **/
	@RequiresPermissions("dictionary:add")
	@ResponseBody
	@RequestMapping("/add")
	public JsonResult add(Model model, Dictionary dictionary) {
		return dictionaryService.add(dictionary, getLoginUser());
	}

	/**
	 * 修改
	 **/
	@RequiresPermissions("dictionary:update")
	@ResponseBody
	@RequestMapping("/update")
	public JsonResult update(Model model, Dictionary dictionary) {
		return dictionaryService.update(dictionary, getLoginUser());
	}

	/**
	 * 批量删除
	 **/
	@RequiresPermissions("dictionary:delete")
	@RequestMapping("/delete")
	@ResponseBody
	public JsonResult delete(Dictionary dictionary ) {
		return dictionaryService.delete(dictionary, getLoginUser());
	}

	/**
	 * 批量删除
	 **/
	@RequestMapping("/dict_code_unique")
	@ResponseBody
	public JsonResult dict_code_unique(Dictionary dictionary ) {
		return dictionaryService.dict_code_unique(dictionary);
	}

}
